/*************************************************************************************
*Copyright (c) 2011, Intel Mobile Communications GmbH. 
*All rights reserved.
*
*Redistribution and use in source and binary forms, with or without
*modification, are permitted provided that the following conditions are met:
*    * Redistributions of source code must retain the above copyright
*      notice, this list of conditions and the following disclaimer.
*    * Redistributions in binary form must reproduce the above copyright
*      notice, this list of conditions and the following disclaimer in the
*      documentation and/or other materials provided with the distribution.
*    * Neither the name of the <organization> nor the
*      names of its contributors may be used to endorse or promote products
*      derived from this software without specific prior written permission.
*
*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
*ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
*DISCLAIMED. IN NO EVENT SHALL INTEL MOBILE COMMUNICATIONS GMBH. BE LIABLE FOR ANY
*DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
*ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************************/



#ifndef CEF_FLOW_H
#define CEF_FLOW_H
#include <string>
#include <vector>
#ifdef _DEBUG
#include <iostream>
#endif 
enum flow_type {WR, RD, WRNP};
class cef_burst_trans
{
	protected:
	unsigned size;
	unsigned long period;
	unsigned long offset;
	unsigned long duration;
	public:
	cef_burst_trans();
	cef_burst_trans(unsigned, unsigned long, unsigned long, unsigned long);
	~cef_burst_trans();	
	//Setters
	void setSize(unsigned);
	void setPeriod(unsigned long);
	void setOffset(unsigned long);
	void setDuration(unsigned long);
	//Getters
	unsigned getSize();
	unsigned long getPeriod();
	unsigned long getOffset();
	unsigned long getDuration();
#ifdef _DEBUG	
	void print();
#endif
};

class cef_burst
{
	protected:
	unsigned length;
	double percent;
	public:
	cef_burst();
	cef_burst(unsigned, double);
	~cef_burst();
	void setLength(unsigned);
	void setPercent(double);
	double getPercent();
	unsigned getLength();
#ifdef _DEBUG
	void print();
#endif
};

class cef_flow
{
	protected:
	std::string type;	
	unsigned id;
	unsigned max_outstanding_transactions;
	double peak_bandwidth;
	double sustained_bandwidth;
	double lat_zl;
	double lat_rt;
	unsigned priority_class;
	bool prioritized;
	int gid;
	std::vector<cef_burst_trans*>* burst_transfers;		
	std::vector<cef_burst*>* burstiness;
	public:
	cef_flow();
	cef_flow(unsigned, std::string, unsigned, double, double, double, double,int, bool,unsigned, std::vector<cef_burst_trans*>* , std::vector<cef_burst*>* );
	~cef_flow();
	//Setters
	void setType(std::string);
	void setID(unsigned);
	void setMOT(unsigned);//max_outstanding_transactions
	void setPeakBW(double);
	void setSustainedBW(double);
	void setZeroLoadLatB(double);
	void setLatB(double);
	void setGID(int);
	void setPriority(unsigned);
	void setPrioritized(bool);
	void setBurstTrans(std::vector<cef_burst_trans*>*);
	void setBurstiness(std::vector<cef_burst*>*);
	void addBurstTrans(cef_burst_trans*);
	void addBurstiness(cef_burst*);

	//Getters
	std::string getType();
	unsigned getID();
	unsigned getMOT();
	double getPeakBW();
	double getSustainedBW();
	double getZeroLoadLatB();
	double getLatB();
	unsigned getPriority();
	bool isPrioritized();
	int getGID();
	std::vector<cef_burst_trans*>* getBurstTrans();
	std::vector<cef_burst*>* getBurstiness();
	cef_burst_trans* getBurstTrans_i(unsigned);
	cef_burst* getBurstiness_i(unsigned);
	unsigned sizeBurstTrans();
	unsigned sizeBurstiness();
#ifdef _DEBUG
	void print();
#endif
};
#endif
